﻿using Microsoft.EntityFrameworkCore;

#nullable disable

namespace Gasgoo.DataProvider.EntityFramework.iToolLogger
{
    public partial class iToolLoggerContext : DbContext
    {
        public iToolLoggerContext()
        {
        }

        public iToolLoggerContext(DbContextOptions<iToolLoggerContext> options) : base(options)
        {
        }

        public virtual DbSet<LogClientException> LogClientExceptions { get; set; }
        public virtual DbSet<LogCustomException> LogCustomExceptions { get; set; }
        public virtual DbSet<LogFunction> LogFunctions { get; set; }
        public virtual DbSet<LogGateway> LogGateways { get; set; }
        public virtual DbSet<LogSystemException> LogSystemExceptions { get; set; }
        public virtual DbSet<LogTracking> LogTrackings { get; set; }

        protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
        {
            if (!optionsBuilder.IsConfigured)
            {
                optionsBuilder
                     .UseSqlServer("Data Source=10.0.1.9;database=iTool.Logger;uid=Gas_News;pwd=QGsga*!H0B1QXfPTo%tfNcc3e");
                //.UseSqlServer(AppSetting.iToolLoggerSqlString);
            }
        }

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS");

            modelBuilder.Entity<LogClientException>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("LogClientException");

                entity.Property(e => e.Category)
                    .HasMaxLength(200)
                    .IsUnicode(false)
                    .HasColumnName("category");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime")
                    .HasColumnName("createTime");

                entity.Property(e => e.Exception).HasColumnName("exception");

                entity.Property(e => e.Id)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("id");

                entity.Property(e => e.Level)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("level");

                entity.Property(e => e.Message).HasColumnName("message");
            });

            modelBuilder.Entity<LogCustomException>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("LogCustomException");

                entity.Property(e => e.Category)
                    .HasMaxLength(200)
                    .IsUnicode(false)
                    .HasColumnName("category");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime")
                    .HasColumnName("createTime");

                entity.Property(e => e.Exception).HasColumnName("exception");

                entity.Property(e => e.Id)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("id");

                entity.Property(e => e.Level)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("level");

                entity.Property(e => e.Message).HasColumnName("message");
            });

            modelBuilder.Entity<LogFunction>(entity =>
            {
                entity.ToTable("LogFunction");

                entity.HasKey(e => e.Id)
                    .HasName("PK_LogFunction");

                entity.Property(e => e.Id)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("id");


                entity.Property(e => e.Channel)
                    .HasMaxLength(60)
                    .HasColumnName("channel");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime")
                    .HasColumnName("createTime");

                entity.Property(e => e.Host)
                    .HasMaxLength(40)
                    .IsUnicode(false)
                    .HasColumnName("host");



                entity.Property(e => e.IsUseState).HasColumnName("isUseState");

                entity.Property(e => e.Parameter)
                    .HasMaxLength(600)
                    .HasColumnName("parameter");

                entity.Property(e => e.Port).HasColumnName("port");

                entity.Property(e => e.RequestBody)
                    .HasMaxLength(600)
                    .HasColumnName("requestBody");

                entity.Property(e => e.RequestFunctionName)
                    .HasMaxLength(600)
                    .HasColumnName("requestFunctionName");

                entity.Property(e => e.RequestModuleName)
                    .HasMaxLength(600)
                    .HasColumnName("requestModuleName");

                entity.Property(e => e.ResponseBody).HasColumnName("responseBody");

                entity.Property(e => e.ResponseState).HasColumnName("responseState");

                entity.Property(e => e.RunTimeTotalMilliseconds).HasColumnName("runTimeTotalMilliseconds");

                entity.Property(e => e.Session)
                    .HasMaxLength(600)
                    .HasColumnName("session");
            });

            modelBuilder.Entity<LogGateway>(entity =>
            {
                entity.ToTable("LogGateway");

                entity.Property(e => e.Id).HasColumnName("ID");

                entity.Property(e => e.Createtime).HasColumnType("datetime");

                entity.Property(e => e.MethodType)
                    .HasMaxLength(25)
                    .IsUnicode(false)
                    .HasColumnName("methodType");

                entity.Property(e => e.RequestDns)
                    .HasMaxLength(15)
                    .IsUnicode(false)
                    .HasColumnName("RequestDNS");

                entity.Property(e => e.RequestForUrl)
                    .HasMaxLength(25)
                    .IsUnicode(false);

                entity.Property(e => e.RequestIp)
                    .HasMaxLength(15)
                    .IsUnicode(false);

                entity.Property(e => e.RequestUrl)
                    .HasMaxLength(25)
                    .IsUnicode(false);
            });

            modelBuilder.Entity<LogSystemException>(entity =>
            {
                entity.HasNoKey();

                entity.ToTable("LogSystemException");

                entity.Property(e => e.Category)
                    .HasMaxLength(200)
                    .IsUnicode(false)
                    .HasColumnName("category");

                entity.Property(e => e.CreateTime)
                    .HasColumnType("datetime")
                    .HasColumnName("createTime");

                entity.Property(e => e.Exception).HasColumnName("exception");

                entity.Property(e => e.Id)
                    .ValueGeneratedOnAdd()
                    .HasColumnName("id");

                entity.Property(e => e.Level)
                    .HasMaxLength(20)
                    .IsUnicode(false)
                    .HasColumnName("level");

                entity.Property(e => e.Message).HasColumnName("message");
            });

            modelBuilder.Entity<LogTracking>(entity =>
            {
                entity.ToTable("LogTracking");

                entity.Property(e => e.Action)
                    .IsRequired()
                    .HasMaxLength(50)
                    .IsUnicode(false);

                entity.Property(e => e.Createtime)
                    .HasColumnType("datetime")
                    .HasColumnName("createtime");

                entity.Property(e => e.Message).HasColumnName("message");

                entity.Property(e => e.Starttime)
                    .HasColumnType("datetime")
                    .HasColumnName("starttime");

                entity.Property(e => e.Token)
                    .IsRequired()
                    .HasMaxLength(50)
                    .IsUnicode(false);
            });

            OnModelCreatingPartial(modelBuilder);
        }

        partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
    }
}
